package sctu.edu.java.year2016.team06.lvjiafu.day20160602.chapter9_1;

/**
 * Created by lvjiafu on 2016/6/2.
 */
import java.util.Scanner;
//外部类

public class Sum {


//内部类

    static  class   Add{


        public  int  Add1(int x) {

            int sum=0;
            for (int i = 1; i <= x;i++)
                sum += i;

            return sum;

        }
    }

    public static void main(String [] args){


        System.out.println("请输入加到哪个数的和：");
        Scanner scan=new Scanner(System.in);
        int x;


        int sum=new Add().Add1(x = scan.nextInt());
        System.out.println("1到"+x+"的和是："+sum);

    }
}
